<template>
    <div class="subord">
        <ul class="sub-dz mui-table-view">
            <li class="mui-table-view-cell">
                <a class="mui-navigate-right">
                    <div class="dz-hed">
                        <span>伯虎点石榴</span>
                        <span>130****5946</span>
                    </div>
                    <div class="dz-bott">
                        <span>默认</span>
                        <span>什么市什么区什么镇什么村什么街道多少号</span>
                    </div>
                </a>
            </li>
        </ul>
        <div class="methPay">
            <span>支付方式</span>
            <div class="met-right">
                <span>在线支付</span>
                <span class="mui-icon mui-icon-more"></span>
            </div>
        </div>
        <div class="distinfo" v-for="item in this.$store.state.orde" :key="item.ordeimg">
            <div class="info-hed">
                <div class="info-hed-img"><img :src="item.ordeimg" alt=""></div>
                <div class="info-hed-right">
                    <p>{{ item.ordename }}</p>
                    <p>
                        <nut-price  :price=item.ordejg :needSymbol="true" :thousands="false"/>
                    </p>
                    <p><span>支持七天无理由退货</span></p>
                </div>
            </div>
            <div class="chasequ">
                <span>购买数量</span>
                <span>×{{ item.ordenum }}</span>
            </div>
            <div class="dist">
                <span>配送</span>
                <div class="dist-right">
                    <div class="right-text">
                        <p>快递运输</p>
                        <span>工作日~双休日与节假日均可送货</span>
                    </div>
                    <span class="mui-icon mui-icon-more"></span>
                </div>
            </div>
            <div class="giving">
                <span>退还无忧 商家赠送</span>
                <p>7天内退货，15天内换货，可享1次运费赔付到小金库</p>
            </div>
        </div>
        <ul class="dedu">
            <li>
                <span>发票</span>
                <div class="dedu-right">
                    <span>不开发票</span>
                    <span class="mui-icon mui-icon-more"></span>
                </div>
            </li>
            <li>
                <span>优惠卷</span>
                <div class="dedu-right">
                    <span>无可用</span>
                    <span class="mui-icon mui-icon-more"></span>
                </div>
            </li>
            <li>
                <span>礼品卡</span>
                <div class="dedu-right">
                    <span>无可用</span>
                    <span class="mui-icon mui-icon-more"></span>
                </div>
            </li>
        </ul>
        <ul class="easy">
            <li>
                <span>商品金额</span>
                <span>￥{{this.subordjg}}</span>
            </li>
            <li>
                <span>运费</span>
                <span style="color: red">+ ￥0.00</span>
            </li>
            <li>
                <span>退换无忧</span>
                <span style="color: red">+ ￥0.00</span>
            </li>
        </ul>
        <div class="sub">
            <div class="sub-text">
                <span>￥</span>
                <span>{{ this.subordjg }}</span>
            </div>
            <div class="sub-right">
                <button type="button" class="mui-btn mui-btn-outlined" @click="cancel">取消订单</button>
                <button type="button" class="mui-btn mui-btn-danger" @click="suborde()">提交订单</button>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    name: "subord",
    data(){
        return{
            subordjg: 0
        }
    },
    methods: {
        getorde(){
            this.$store.state.orde.forEach(element => {
                let x = (parseFloat(element.ordejg) * parseInt(element.ordenum)).toFixed(2)
                this.subordjg = (parseFloat(this.subordjg) + parseFloat(x)).toFixed(2)
            });
        },
        cancel(){
            this.$router.go(-1) //上一步
        },
        suborde(){
            if(this.$route.path.match("shop") == "shop"){
                this.$toast.success('提交成功！')
                setTimeout(() =>{
                    this.$router.push('/shop')
                    localStorage.setItem("car",JSON.stringify([]))
                    localStorage.setItem("carOf",JSON.stringify(0))
                    this.$store.state.carOf = 0
                    location.reload()
                },2000)
            }else{
                this.$toast.success('提交成功！')
                setTimeout(() => {
                    this.cancel()
                },2000)
            }
        }
    },
    created(){
        this.getorde()
    }
}
</script>

<style scoped>
    .subord{
        width: 100%;
        height: 100%;
    }
    .subord .sub-dz .dz-hed{
        margin-bottom: 10px;
    }
    .subord .sub-dz .dz-hed span:nth-child(1){
        font-size: 18px;
        margin-right: 20px;
    }
    .subord .sub-dz .dz-bott span:nth-child(1){
        display: inline-block;
        width: 30px;
        height: 20px;
        font-size: 10px;
        background-color: red;
        border-radius: 50px;
        text-align: center;
        color: #ffffff;

    }
    .subord .sub-dz .dz-bott span:nth-child(2){
        font-size: 14px;
    }
    .subord .methPay{
        width: 100%;
        height: 60px;
        margin: 10px 10px 0 0;
        line-height: 60px;
        padding: 0 20px;
        background-color: #ffffff;
    }
    .subord .methPay span:nth-child(1){
        float: left;
    }
    .subord .methPay .met-right{
        float: right;
    }
    .subord .methPay .met-right span:nth-child(1){
        margin-right: 10px;
    }
    .subord .distinfo{
        width: 100%;
        background-color: #ffffff;
        margin-top: 10px;
        padding: 10px;
    }
    .subord .distinfo .info-hed{
        width: 100%;
        height: 90px;
    }
    .subord .distinfo .info-hed .info-hed-img{
        width: 90px;
        height: 90px;
        float: left;
    }
    .subord .distinfo .info-hed .info-hed-img img{
        width: 100%;
        height: 100%;
    }
    .subord .distinfo .info-hed .info-hed-right{
        width: 70%;
        height: 90px;
        float: right;
    }
    .subord .distinfo .info-hed .info-hed-right p{
        font-size: 16px;
        margin-bottom: 0;
        margin-top: 5px;
        color: black;
    }
    .subord .distinfo .info-hed .info-hed-right p:nth-child(2){
        color: red;
    }
    .subord .distinfo .info-hed .info-hed-right p:nth-child(3) span{
        display: inline-block;
        font-size: 12px;
        width: 130px;
        height: 20px;
        text-align: center;
        line-height: 18px;
        border-radius: 50px;
        color: red;
        border: 0.5px solid red;
    }
    .subord .distinfo .chasequ{
        width: 100%;
        height: 50px;
        line-height: 50px;
        font-size: 15px;
        font-weight: 500;
    }
    .subord .distinfo .chasequ span:nth-child(2){
        float: right;
        margin-right: 20px;
    }
    .subord .distinfo .dist{
        width: 100%;
        height: 70px;
    }
    .subord .distinfo .dist .dist-right{
        float: right;
    }
    .subord .distinfo .dist .dist-right .right-text{
        float: left;
        font-size: 14px;
        text-align: right;
        color: black;
        margin-right: 30px;
    }
    .subord .distinfo .dist .dist-right .right-text p{
        font-size: 14px;
        color: black;
        margin-bottom: 5px;
        margin-top: 10px;
    }
    .subord .distinfo .dist .dist-right .mui-icon{
        float: right;
        margin-top: 20px;
        margin-right: 10px;
    }
    .subord .distinfo .giving{
        width: 100%;
    }
    .subord .distinfo .giving span{
        font-size: 14px;
        margin-top: 5px;
    }
    .subord .distinfo .giving p{
        font-size: 13px;
    }
    .subord .dedu{
        width: 100%;
        background-color: #ffffff;
        margin-top: 10px;
        padding: 10px;
    }
    .subord .dedu li{
        width: 100%;
        height: 40px;
        line-height: 40px;
        font-size: 15px;
    }
    .subord .dedu .dedu-right{
        float: right;
    }
    .subord .dedu .dedu-right span{
        margin-right: 10px;
    }
    .subord .easy{
        width: 100%;
        height: 100px;
        background-color: #ffffff;
        padding: 10px;
        margin-top: 10px;
        margin-bottom: 60px;
    }
    .subord .easy li{
        width: 100%;
        height: 30px;
        line-height: 30px;
        font-size: 15px;
    }
    .subord .easy li span:nth-child(2){
        float: right;
        margin-right: 10px;
    }
    .subord .sub{
        width: 100%;
        height: 50px;
        position: fixed;
        bottom: 50px;
        background-color: #ffffff;
        line-height: 50px;
    }
    .subord .sub .sub-text{
        display: inline;
        margin-left: 20px;
    }
    .subord .sub .sub-text span{
        color: red;
    }
    .subord .sub .sub-text span:nth-child(1){
        font-size: 15px;
    }
    .subord .sub .sub-text span:nth-child(2){
        font-size: 19px;
    }
    .subord .sub .sub-right{
        float: right;
    }
    .subord .sub .sub-right button:nth-child(1){
        background-color: rgb(129, 129, 129)
    }
    .subord .sub .sub-right button{
        color: #ffffff;
        width: 100px;
        height: 50px;
        border: 0;
        margin: 0;
    }
</style>

